//
//  ViewController.m
//  文本框_UITextfield
//
//  Created by mir_yan on 2018/10/3.
//  Copyright © 2018年 hakeem. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view setBackgroundColor:[UIColor darkGrayColor]];
    
    UITextField* textField = [[UITextField alloc] initWithFrame:CGRectMake(20, 50, CGRectGetWidth(self.view.frame) - 40, 100)];
    // 一般不会对文本框添加target:action 操作 交互 通过委托 通知技术实现
    [self.view addSubview:textField];
    
    textField.borderStyle = UITextBorderStyleRoundedRect;
    
    textField.textColor = [UIColor redColor];
    [textField setTextAlignment:NSTextAlignmentCenter];
    
    // 设置文本
    textField.text = @"刘备";
    // 设置提示文本
    textField.placeholder = @"输入昵称";
    
    UIImageView* leftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(2, 2, 25, 25)];
    leftImageView.image = [UIImage imageNamed:@"1.jpg"];
    // 设置左视图显示
    [textField setLeftViewMode:UITextFieldViewModeAlways];
    [textField setLeftView:leftImageView];
    
    [textField setFont:[UIFont systemFontOfSize:20]];
    [textField setMinimumFontSize:15.0f];
    
    // 清除按钮显示设置
    [textField setClearButtonMode:UITextFieldViewModeAlways];
    // 开始编辑前自动清除文本
    [textField setClearsOnBeginEditing:YES];
    
    // 设置键盘
    [textField setKeyboardType:UIKeyboardTypeDefault];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
